

package com.zj.mes.sys.service.impl;

import com.zj.mes.common.entity.Resource;
import com.zj.mes.common.entity.ResultModel;
import com.zj.mes.sys.mapper.PermissionMapper;
import com.zj.mes.sys.service.IPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Copyright (C), 2015-2019
 * FileName: PermissionServiceImpl
 * Author:   王晓楠
 * Date:     2019/7/18 10:29
 * Description:
 */
@Service
public class PermissionServiceImpl implements IPermissionService {
    @Autowired
    private PermissionMapper permissionMapper;
    @Autowired
    ResultModel model;
    @Override
    public ResultModel getPower(Integer state) {
        //查询所有的权限
        model.setResultStatus(0);
        model.setMessage("查询成功");
        model.setObject(permissionMapper.getPower(state));
        return model;
    }

    @Override
    public ResultModel updatePermissionStatus(Integer id, Integer status) {
        int count = permissionMapper.updatePermissionStatus(id, status);
        //影响行数
        if (count > 0) {
            model.setResultStatus(0);
            model.setMessage("变更成功");
            model.setObject("");
        } else {
            model.setResultStatus(1);
            model.setMessage("变更失败");
            model.setObject("");
        }
        return model;
    }
}
